package util;

import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;

/**
 * @author wanglei
 * @date 2021/10/21
 * */
public class SocketUtil {
    /**
     * 检查某个服务端口是否正常
     *
     * @author wanglei
     * @date 2021/10/21
     * */
    public static String check(String ip, int port) {
        try {
            Socket socket = new Socket();
            SocketAddress add = new InetSocketAddress(ip, port);
            socket.connect(add, 1000);
            socket.close();
            return "ok";
        } catch (Exception e) {
            return "error";
        }
    }
}